package com.hyt.it.ogt.controller.ykcj.grade;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hyt.it.ogt.controller.base.BaseController;
import com.hyt.it.ogt.ykcj.common.annotation.Log;
import com.hyt.it.ogt.ykcj.common.core.domain.AjaxResult;
import com.hyt.it.ogt.ykcj.common.core.page.TableDataInfo;
import com.hyt.it.ogt.ykcj.common.enums.BusinessType;
import com.hyt.it.ogt.ykcj.common.utils.poi.ExcelUtil;
import com.hyt.it.ogt.ykcj.domain.grade.ServantSubjectPtGradeAnalysisData;
import com.hyt.it.ogt.ykcj.service.grade.IServantSubjectPtGradeAnalysisDataService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiSort;

/**
 * 公务员考试科目层级成绩数据分析Controller
 *
 * @author admin
 * @date 2021-10-13
 */
@Api(tags = "grade.8.公务员考试科目层级成绩数据分析", value = "公务员考试科目层级成绩数据分析请求接口")
@ApiSort(value = 208)
@RestController
@RequestMapping("/grade/servantSubjectPtGradeAnalysisData")
public class ServantSubjectPtGradeAnalysisDataController extends BaseController {

  @Autowired
  private IServantSubjectPtGradeAnalysisDataService servantSubjectPtGradeAnalysisDataService;

  /**
   * 查询公务员考试科目层级成绩数据分析列表
   */
  @GetMapping("/list")
  public TableDataInfo list(ServantSubjectPtGradeAnalysisData servantSubjectPtGradeAnalysisData) {
    startPage();
    List<ServantSubjectPtGradeAnalysisData> list = servantSubjectPtGradeAnalysisDataService
        .selectServantSubjectPtGradeAnalysisDataList(servantSubjectPtGradeAnalysisData);
    return getDataTable(list);
  }

  /**
   * 导出公务员考试科目层级成绩数据分析列表
   */
  @Log(title = "公务员考试科目层级成绩数据分析", businessType = BusinessType.EXPORT)
  @GetMapping("/export")
  public AjaxResult export(ServantSubjectPtGradeAnalysisData servantSubjectPtGradeAnalysisData) {
    List<ServantSubjectPtGradeAnalysisData> list = servantSubjectPtGradeAnalysisDataService
        .selectServantSubjectPtGradeAnalysisDataList(servantSubjectPtGradeAnalysisData);
    ExcelUtil<ServantSubjectPtGradeAnalysisData> util = new ExcelUtil<>(ServantSubjectPtGradeAnalysisData.class);
    return util.exportExcel(list, "公务员考试科目层级成绩数据分析数据");
  }

  /**
   * 获取公务员考试科目层级成绩数据分析详细信息
   */
  @GetMapping(value = "/{id}")
  public AjaxResult getInfo(@PathVariable("id") String id) {
    return AjaxResult.success(
        servantSubjectPtGradeAnalysisDataService.selectServantSubjectPtGradeAnalysisDataById(id));
  }

  /**
   * 新增公务员考试科目层级成绩数据分析
   */
  @Log(title = "公务员考试科目层级成绩数据分析", businessType = BusinessType.INSERT)
  @PostMapping
  public AjaxResult add(
      @RequestBody ServantSubjectPtGradeAnalysisData servantSubjectPtGradeAnalysisData) {
    return toAjax(servantSubjectPtGradeAnalysisDataService
        .insertServantSubjectPtGradeAnalysisData(servantSubjectPtGradeAnalysisData));
  }

  /**
   * 修改公务员考试科目层级成绩数据分析
   */
  @Log(title = "公务员考试科目层级成绩数据分析", businessType = BusinessType.UPDATE)
  @PutMapping
  public AjaxResult edit(
      @RequestBody ServantSubjectPtGradeAnalysisData servantSubjectPtGradeAnalysisData) {
    return toAjax(servantSubjectPtGradeAnalysisDataService
        .updateServantSubjectPtGradeAnalysisData(servantSubjectPtGradeAnalysisData));
  }

  /**
   * 删除公务员考试科目层级成绩数据分析
   */
  @Log(title = "公务员考试科目层级成绩数据分析", businessType = BusinessType.DELETE)
  @DeleteMapping("/{ids}")
  public AjaxResult remove(@PathVariable String[] ids) {
    return toAjax(
        servantSubjectPtGradeAnalysisDataService.deleteServantSubjectPtGradeAnalysisDataByIds(ids));
  }
}
